package org.example;

public class Test3 {
    //leetcode 盛最多水的容器
    //https://leetcode.cn/problems/container-with-most-water/description/
    public int maxArea(int[] height) {
        int n = height.length;
        int slow = 0, fast = n-1;
        int ret = 0;
        while (slow < fast) {
            ret = Math.max(ret,Math.min(height[slow],height[fast]) * (fast-slow));
            if (height[slow] < height[fast]) slow++;
            else fast--;
        }
        return ret;
    }
}
